package org.rcy.framework.file.doc;

import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 吴康桥
 * @Description
 * @date 2022/12/13 11:56
 */


public class PoiDocService {

	public XWPFDocument readDocument(InputStream is) throws IOException {
		return new XWPFDocument(is);
	}

	public List<String> getDocumentText(XWPFDocument document){
		List<XWPFParagraph> paragraphs = document.getParagraphs();
		List<String> testList = paragraphs.stream().map(p -> p.getText()).collect(Collectors.toList());
		return testList;
	}
}
